{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css">
<link rel="stylesheet" href="__CSS__/jquery-weui.css">
<style>

    .form-head{
        color: white;
        font-size: 16px;
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 5px;
        overflow: hidden;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-repeat:no-repeat;
        background-size:cover;
        text-align: center;
    }
    textarea{

        outline: none;
        color: #000000;
        position: relative;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0.9);
        float: left;
        margin:auto;
        font-size: 16px;
        height:80px;
        border-radius: 5px;
        width:60%;
        font-family: "Microsoft YaHei UI";
    }
    .store-info{
        border-bottom:1px solid #ddd;
        width:95%;
        margin: auto;
        height: 72px;
    }
    .name-position{
        padding-left: 10px;
        margin-left: 20px;
        margin-top: 1em;
    }
    .store-info img{
        width:50px;
        height: 50px;
        vertical-align: sub;
        float: left;
        border-radius: 50%;
        margin-left: 20px;
        margin-right: 20px;
    }
    .store-info-p1{
        color: #eeeeee;
        font-size: 18px;
        width:60%;
        margin-top: 10px;
        overflow: hidden;
        text-align: left;
        margin-left: 20px;
     }
    .store-info-p2{
        color: deepskyblue;
        font-size: 14px;
        width:60%;
        overflow: hidden;
        text-align: left;
        margin-left: 20px;
        text-overflow:ellipsis;
        white-space: nowrap;
    }
    .login-btn2{
        width:70%;
        height:40px;
    }
    .form-input3-label{
        width:30%;
        margin: 0;
    }
    .first_offer{
        color:white;
    }
</style>
{/block}
{block name="body"}
<div class="store-info" onclick="">

        <div style="overflow:hidden;padding-bottom:10px;">
            <img src="__BASE__/index.php/picture/index?id={$detail.seller.logo}">
            <div class="name-position">
                <p class="store-info-p1">{$detail.seller.name}</p>
                <p class="store-info-p2" >{$detail.seller.position}</p>
            </div>
        </div>

</div>
<form action="{:url('shop/order')}" method="post" style="width:95%;margin: auto">
<div style="margin-top: 20px">
    <input  id="seller_id" name="seller_id" type="hidden" value="{$seller_id}" >
    <input  id="seller_name" name="seller_name" type="hidden" value="{$detail.seller.name}" >
    <div class="form-input3" >
        <label for="amount" class="form-input3-label">消费总额:</label>
        <input class="form-input4-input" id="amount" name="amount" type="text" style="padding:5px;background-color: rgba(95, 110, 170, 0.3);color:white" value="" placeholder=" ">
    </div>
    <div class="form-input3">
        <label for="no_discount" class="form-input3-label">不优惠金额:</label>
            <input class="form-input4-input" name="no_discount" id="no_discount" style="padding:5px;background-color: rgba(95, 110, 170, 0.3);color:white" type="text" value="0">
    </div>
    <div class="form-input4">
        <label for="note" class="form-input3-label">备注:</label>
        <input type="text" class="form-input4-input" name="note" style="padding:5px;background-color: rgba(95, 110, 170, 0.3);color:white;line-height: 25px" id="note" style="">

        </input>
    </div>
    <div class="first_offer">{if condition="$firstinfo.is_first == 1"}
                                 {switch name= "$firstinfo.first_offer"}
                                    {case value="500"}本次消费是首次消费，满30减5{/case}
                                    {case value="1000"}本次消费是首次消费，满100-10{/case}
                                    {case value="2000"}本次消费是首次消费，满200-20{/case}
                                    {default /}
                                 {/switch}
                            {/if}
    </div>
</div>

    <div class="form-input">
        <button id="submit" class="login-btn2" type="button">提交</button>
    </div>
</form>
<script type="text/javascript" src="__JS__/public.js"></script>
<script>

</script>
{/block}
{block name="footer"}
<script>
    $('#submit').click(function () {
        if(isNaN($('#amount').val())||isNaN($('#no_discount').val())){
            $.toptip("请输入正确金额");
            return false;
        }
            var body  ={
                amount:$('#amount').val(),
                no_discount:$('#no_discount').val(),
                seller_id:$('#seller_id').val(),
                seller_name:$('#seller_name').val(),
                note:$('#note').val()
            };

            var $this = $(this);
            $this.addClass('weui-btn_disabled').attr('disabled','disabled');
            ajax_post(getBaseUrl()+'web.php/shop/order',jQuery.param(body),{
                success:function(data){
                    $.toast("订单生成成功",'success');
                //    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                    setTimeout(
                            function(){
                                location.href=getBaseUrl()+'web.php/wxpay/jump2pay?order_code='+data.data.order_code+'&price='+data.data.price+'&seller_name='+data.data.seller_name;
                            }
                            ,100);
                },
                error:function(data){
                    $.toptip('订单生成失败', 'error');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                }
            })


    });

</script>
{/block}